/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/5/20 20:57
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.component.gallery.service.task;

import com.example.common.api.service.base.TaskHandler;
import com.example.component.gallery.service.bing.impl.BingImageCollector;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-07-03 23:56
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-07-03
 * @modify reason: {方法名}:{原因}
 * ...
 */
@Configuration
@EnableScheduling
@Slf4j
public class GalleryScheduleTask implements TaskHandler {

    @Resource
    private BingImageCollector bingImageCollector;

    /**
     * 任务执行体
     *  每天0点执行一次,保存必应图片
     */
    @Override
    @Scheduled(cron = "0 0 0 * * ?")
    public void handle() {
        log.info("BingImageCollector定时任务开始执行");
        bingImageCollector.collect();
    }
}
